package crivia.ecp.carry.eb;

import java.lang.reflect.Field;
import java.util.Map;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;

public class JspTagExecuter {
	
	public JspTagExecuter(PageContext pageContext
			, Class<? extends TagSupport> tagType
			, Map<String,Object> params) throws Exception {
		this.params = params;
		tag = tagType.newInstance();
		tag.setPageContext(pageContext);
	}
	private Map<String,Object> params;
	private TagSupport tag;
	public void begin() throws JspException{
		for (String s : params.keySet()){
			try {
				Field f = tag.getClass().getDeclaredField(s);
				f.setAccessible(true);
				f.set(tag, params.get(s));
				f.setAccessible(false);
			} catch (Exception e) {}
		}
		tag.doStartTag();
	}
	public void end() throws JspException{
		tag.doEndTag();
	}
	
	
	
	
	

}
